package com.seagox.chat.auth.controller;

import com.seagox.chat.auth.serivce.IAuthService;
import com.seagox.chat.chat.service.IVersionRecordService;
import com.seagox.chat.common.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 认证
 */
@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private IAuthService authService;
    
    @Autowired
    private IVersionRecordService versionRecordService;

    /**
     * 登陆
     *
     * @param account  用户名
     * @param password 密码
     */
    @PostMapping("/login")
    public ResultData login(String account, String password) {
        return authService.login(account, password);
    }
    
    /**
     * 下载桌面版
     */
    @PostMapping("/download")
    public ResultData download(String platform, String arch) {
        return versionRecordService.download(platform, arch);
    }
    
    /**
     * 验证登陆
     *
     * @param account      用户名
     * @param noncestr     随机数
     * @param timestampStr 时间戳
     * @param sign         签名
     */
    @PostMapping("/verifyLogin")
    public ResultData verifyLogin(String account, String noncestr, String timestampStr, String sign) {
        return authService.verifyLogin(account, noncestr, timestampStr, sign);
    }
    
}
